home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 20
/
020.d81
/
t.pps #45
< prev
next >
Wrap
Text File
|
2022-08-26
|
2KB
|
117 lines
======================================
PEEKs, POKEs, & SYSes, part 45
by Jim Weiler and Reggie Beavers
======================================
---------------
HOW PITCH WORKS
---------------
Whenever SID finds a "wave on"
value in one of his waveform
registers, he makes noise at a
specific frequency. That frequency
is determined by the values in his
pitch registers. (S+0 and S+1 are
the pitch registers for voice 1.)
S+0 holds the low byte of pitch and
S+1 contains the high byte. SID
doesn't care whether the value in the
pitch registers is stable or
fluctuating. He will always try to
play the pitch described therein.
That makes it possible to step from
one note to another, or to slide
gently through the scales. It all
depends on how smoothly you change
the values in the pitch registers.
Here, again, is the BASIC
code to make SID play a C-sharp.
1 S = 54272
2 POKE S+0,12:POKE S+1,71 (c-sharp)
3 POKE S+24,15 (volume)
4 POKE S+5,9:POKE S+6,0 (envelope)
5 POKE S+4,33 (play it)
6 FOR A=1 TO 200: NEXT (delay it)
7 POKE S+4,32 (stop it)
Line 2 is what we're interested in
this time. How does POKE S+0,12:
POKE S+1,71 translate into C-sharp?
Well... um... it just DOES. When SID
finds pitch registers containing the
value 18188 (that's 71*256 + 12) it
puts out a tone with the same pitch
as C-SHARP. It's completely
arbitrary, but it's also completely
true. What about the rest of the
notes? Look in the last PEEKs,
POKEs, and SYSes article for the
details.
------
SLIDER
------
You aren't limited to playing
single notes, one after the other.
As I implied before, you can change
pitch on the fly just by poking new
values into the pitch registers.
Let's say we wanted that C-sharp tone
we generated above to slide down an
octave to the next lower C-sharp,
like a slide whistle. All we have to
do is change our delay loop to make
it poke new pitches into the pitch
registers:
6 FOR A=71 TO 35 STEP-.15:POKE S+1,A:
NEXT: POKE S+0,134
====<continued in next article>====